﻿#region Using
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
#endregion Using

namespace LloydGame
{
    public class ScreenComponentSwitch : GameScreenComponent
    {
        #region Fields
        protected bool m_value;
        protected Vector2 m_title_pos;
        protected Texture2D m_tex_true, m_tex_false;
        #endregion Fields

        #region Properties
        public bool value { get { return m_value; } set { value = m_value; } }
        #endregion

        #region Constructor
        public ScreenComponentSwitch(String p_title, bool p_value, Vector2 p_pos, Vector2 p_size, Game p_game) :
            base(p_title, p_pos, p_size, p_game)
        {
            m_value = p_value;
            m_title_pos = new Vector2(m_pos.X + 36, m_pos.Y + 4);
            m_tex_true = Texture2D.FromFile(((Game1)p_game).GraphicsDevice, "Content\\switch_component_true.png");
            m_tex_false = Texture2D.FromFile(((Game1)p_game).GraphicsDevice, "Content\\switch_component_false.png");
        }
        #endregion

        #region Draw
        public override void Draw(SpriteBatch p_spritebatch, bool p_active)
        {
            // Title
            p_spritebatch.DrawString(m_smallfont, m_title, m_title_pos + Vector2.One, Color.Black);
            if (m_active)
                p_spritebatch.DrawString(m_smallfont, m_title, m_title_pos, Color.DimGray);
            else
                p_spritebatch.DrawString(m_smallfont, m_title, m_title_pos, Color.White);

            // Value box
            if (m_active)
            {
                if (m_value)
                    p_spritebatch.Draw(m_tex_true, m_pos, Color.LightGray);
                else
                    p_spritebatch.Draw(m_tex_false, m_pos, Color.LightGray);
            }
            else
            {
                if (m_value)
                    p_spritebatch.Draw(m_tex_true, m_pos, Color.White);
                else
                    p_spritebatch.Draw(m_tex_false, m_pos, Color.White);
            }
        }
        #endregion

        #region SwitchValue
        public void SwitchValue()
        {
            m_value = !m_value;
        }
        #endregion
    }
}
